package com.egoo.ticket.server.config.mq;

import com.alibaba.fastjson.JSONObject;
import com.egoo.ticket.server.utils.common.ConstantCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Auther: victor_tang
 * @Date: 2020/8/9 15:23
 * @Description: MQ公共方法
 */
@Component
@Slf4j
public class MqCommonUtil {

	@Autowired
	private AmqpTemplate amqpTemplate;
	@Autowired
	private RabbitMqConfig rabbitMqConfig;

	/**
	 * TODO 推送消息至消息通知通用队列
	 * @author: victor_tang
	 * @createtime: 2020/11/26 13:36
	 * @param workOrderId 1
	 * @param msgNotifyType 2
	 * @return: void
	 */
    public void pushToMsgGeneralQueue(String msgNotifyType,String workOrderId){
		// 推送流转通知信息至MQ
		JSONObject jsonObject = new JSONObject();
		jsonObject.put(ConstantCode.MsgParam.WORK_ORDER_ID,workOrderId);
		jsonObject.put(ConstantCode.MsgParam.MSG_NOTIFY_TYPE, msgNotifyType);
		log.info("推送流传通知消息至mq参数为："+jsonObject);
		amqpTemplate.convertAndSend(rabbitMqConfig.WORKORDER_GENERAL,jsonObject.toJSONString());
	}
	/**
	 * TODO 推送消息至触发器队列
	 * @author: victor_tang
	 * @createtime: 2020/11/26 13:49
	 * @param workOrderId 1
	 * @return: void
	 */
    public void pushToMsgTriggerQueue(String workOrderId){
		log.info("推送触发器消息至MQ参数为："+workOrderId);
		amqpTemplate.convertAndSend(rabbitMqConfig.WORKORDER_TRIGGER,workOrderId);
	}
	/**
	 * TODO 推送消息至内管同步数据队列
	 * @author: victor_tang
	 * @createtime: 2020/11/26 13:49
	 * @param param 1
	 * @return: void
	 */
    public void pushToMsgSyneurmdataQueue(String param){
		log.info("推送内管同步消息至MQ参数为："+param);
		amqpTemplate.convertAndSend(rabbitMqConfig.WORKORDER_SYNEURMDATA,param);
	}
}
